﻿using XCore.Helper;
using XCore.Logger;
using XCore.Dependency;
using XCore.Extensions;

namespace SaaS.Core.Logger
{
    public class TraceLogger : LoggerBase, ISingletonDependency
    {
        public TraceLogger() : base(CoreSetting.RedisConnectionString, CoreSetting.SYSTEM_TRACE, CoreSetting.LOG_INDEX)
        {

        }
        public void Log(string path)
        {
            LoggerInfo ei = new LoggerInfo();
            ei.Properties["Path"] = path;
            ei.Properties["Duration"] = StopwatchHelper.Milliseconds;
            ei.Properties["Type"] = (byte)HttpContext.GetOperatingType();
            ei.Properties["CreationIpAddress"] = HttpContext.GetIp();
            ei.Properties["RequestInfo"] = HttpContext.GetRequestInfo();
            base.RedisLog(ei);
        }
    }
}
